# Neupane et al, 2018
# 
# Codes used for data processing
# Identification and Characterization of Mitogen Activated Protein Kinase (MAPK) Genes in Sunflower (Helianthus annuus L.) 

#---------------------------------------------In Unix-------------------------------------------------------

#Logged in to SOUTH DAKOTA STATE UNIVERSITY High Performance Cluster
ssh username@blackjack

###Download SRR files
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/005/SRR4996815/SRR4996815_1.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/005/SRR4996815/SRR4996815_2.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/009/SRR4996819/SRR4996819_1.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/009/SRR4996819/SRR4996819_2.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/003/SRR4996823/SRR4996823_1.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/003/SRR4996823/SRR4996823_2.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/008/SRR4996828/SRR4996828_1.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/008/SRR4996828/SRR4996828_2.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/004/SRR4996834/SRR4996834_1.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/004/SRR4996834/SRR4996834_2.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/006/SRR4996836/SRR4996836_1.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/006/SRR4996836/SRR4996836_2.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/009/SRR4996839/SRR4996839_1.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/009/SRR4996839/SRR4996839_2.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/007/SRR4996847/SRR4996847_1.fastq.gz
wget ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR499/007/SRR4996847/SRR4996847_2.fastq.gz

###gunzip files
##for one pair samples, run
gunzip SRR4996815_1.fastq.gz
gunzip SRR4996815_2.fastq.gz

###Qulity control of raw data using FastQC 
#For one pair raw read files,run
fastqc SRR4996815_1.fastq
fastqc SRR4996815_2.fastq


###Btrim64 to trim low-quality bases
#for one pair raw read files, run
btrim64-static -q -t /path/to/file/SRR4996815_1.fastq -o /path/for/output/file/SRR4996815_1_trimmed.fastq
btrim64-static -q -t /path/to/file/SRR4996815_2.fastq -o /path/for/output/file/SRR4996815_2_trimmed.fastq


###Activate Biconda Channel
conda activate environment_name

##Run Salmon tool
 
#Buid Index
salmon index -t /path/to/file/Hannuus_494_r1.2.transcript.fa.gz -i /path/for/output/file/Ha_transcripts_index --type quasi -k 31

##Quantify reads
#for one one pair trimmed files
salmon quant -i /path/to/file/Ha_transcripts_index -l A -1 /path/to/file/SRR4996815_1_trimmed.fastq -2 /path/to/file/SRR4996815_2_trimmed -o SRR4996815_count


#---------------------------------------------------------Customized R codes via iDEP 0.81-----------------------------------------------------
# hierarchical clustering tree
 x <- readData.out$data
 maxGene <- apply(x,1,max)

# Parameters for heatmap 
 input_geneCentering <- TRUE	#centering genes ?
 input_sampleCentering <- FALSE	#Center by sample?
 input_geneNormalize <- TRUE	#Normalize by gene?
 input_sampleNormalize <- FALSE	#Normalize by sample?
 input_noSampleClustering <- FALSE	#Use original sample order
 input_heatmapCutoff <- 4	#Remove outliers beyond number of SDs 
 input_distFunctions <- 1	#which distant funciton to use (Correlation)
 input_hclustFunctions <- 1	#Linkage type (Average)
 input_heatColors1 <- 5	#Colors (Blue-white-brown)
 

